/**
* 作者: clz
* 日期: 2025-05-04 16:45:28
* 备注: 联盟折扣商店信息
*/
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.commondata.union.UnionDiscountShop;
import com.motu.monstercity.server.game.logic.UnionManager;
import com.motu.vertx.module.utility.toolset.TimeUtils;
import com.motu.vertx.module.utility.toolset.Tool;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

import java.util.List;

public class UnionDiscountShopInfo extends UnionDiscountShopInfoModel {
	public UnionDiscountShopInfo() {
		super();
	}

	public UnionDiscountShopInfo(long unionId) {
		putId(unionId);
		ramdonDiscountShop();
		putResetTime(TimeUtils.getCurTime());
	}

	public void reset() {
		if (!TimeUtils.isToday(getResetTime())) {
			putDiscountPrice(0);
			ramdonDiscountShop();
			update();
		}
	}

	/**
	 * 随机折扣商店物品
	 */
	public void ramdonDiscountShop() {
		List<UnionDiscountShop> shopList = UnionManager.getUnionDiscountShopMapList();
		int randomIndex = Tool.getRandom(0,shopList.size() - 1);
		UnionDiscountShop unionDiscountShop = shopList.get(randomIndex);
		int shopId = unionDiscountShop.getId();
		putShopId(shopId);//随机分配折扣商店物品
		putResetTime(TimeUtils.getCurTime());
		putInitPrice(unionDiscountShop.getNum());
	}
}
